﻿using IM.Easy.Core.Audit;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IM.Easy.Entity.System
{
    /// <summary>
    /// 系统角色
    /// </summary>
    [SugarTable("SysRole")]
    public class SysRole : AuditableEntity, IOrderable, IActive
    {
        public SysRole()
        {
            IsActive = true;
        }
        /// <summary>
        /// 角色名称
        /// </summary>
        [SugarColumn(Length = 50)]
        public string Name { get; set; }

        /// <summary>
        /// 角色编码
        /// </summary>
        [SugarColumn(Length = 50)]
        public string Code { get; set; }

        /// <summary>
        /// 角色描述
        /// </summary>
        [SugarColumn(Length = 200)]
        public string? Description { get; set; }

        /// <summary>
        /// 是否系统内置
        /// </summary>
        [SugarColumn(IsNullable = false)]
        public bool IsSystem { get; set; }

        /// <summary>
        /// 是否处于活动状态
        /// </summary>
        public bool IsActive { get; set; }

        public int Order { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [Navigate(NavigateType.OneToMany, nameof(SysRoleMenu.RoleId))]
        public List<SysRoleMenu> RoleMenus { get; set; }

        [Navigate(typeof(SysRoleMenu), nameof(SysRoleMenu.RoleId), nameof(SysRoleMenu.MenuId))]
        public List<SysMenu> Menus { get; set; }

        [Navigate(typeof(SysUserRole), nameof(SysUserRole.RoleId), nameof(SysUserRole.UserId))]
        public List<SysUser> Users { get; set; }
    }
}
